package cn.jhc.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/register.do")
public class RegisterServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = request.getParameter("name");
        String password = request.getParameter("password");
        String passwordAgain = request.getParameter("passwordAgain");
        String phoneNumber = request.getParameter("phoneNumber");
        if(!password.equals(passwordAgain)) {
            response.sendRedirect("failedPassword.jsp");
        }else if ("".equals(name) || "".equals(password) || "".equals(passwordAgain) || "".equals(phoneNumber)) {
            response.sendRedirect("failedEmpty.jsp");
        }else {
            response.sendRedirect("registersuccess.jsp");
        }
    }
}
